﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TTS;
using TTSBLL;

public partial class Repair : System.Web.UI.Page
{

    private string sn { get { return ViewState["sn"].ToString(); } set { ViewState["sn"] = value; } }
    private string message ;
    private KCCSNUnion kccDelete;
    private const string storedProcedureName = "KCCSNUnion_delete";

    protected void Page_Load(object sender, EventArgs e)
    {
       // sn = this.KCCSN_Text.Text.Trim();
        this.KCCSN_Text.Focus();
    }
    public Repair()
    {
        kccDelete = new KCCSNUnion();
    }

    protected void Return_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Repair/RRH/RRHRepairHtml.aspx");
    }
    protected void Repair_Click(object sender, EventArgs e)
    {
        /*sn = this.KCCSN_Text.Text.Trim();
        if (!string.IsNullOrEmpty(sn))
        {
           if (SNHelper.KccUpSNCheck(sn, out message))
            {
                if (!string.IsNullOrEmpty(kccDelete.KCCSNUnion_GetbyKCCSN1(sn).SN))
                {
                    kccDelete.KCCSNUnion_DeletebyKCCSN1(sn);
                    message = "装配关系解锁成功！";
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
                    this.KCCSN_Text.Text = "";
                }
                else
                {
                    message = "该" + sn + "在数据库中无装配记录，请重新扫描正确的KCC！";
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
                    this.KCCSN_Text.Text = "";
                }
            }
           else
           {
               ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
               this.KCCSN_Text.Text = "";
           }                     
        }
        else
        {
            message = "请确保输入框不能为空！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        }*/
        kccDelete.KCCSNUnion_DeletebyKCCSN1(sn, storedProcedureName);
        message = "装配关系解锁成功！";
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
        this.KCCSN_Text.Text = "";
        this.Remove.Enabled = false;
    }


    protected void KCCSN_Text_TextChanged(object sender, EventArgs e)
    {
        sn = this.KCCSN_Text.Text.Trim();
       
            if (SNHelper.KccUpSNCheck(sn, out message))
            {
                if (!string.IsNullOrEmpty(kccDelete.KCCSNUnion_GetbyKCCSN1(sn).SN))
                {
                    this.Remove.Enabled = true;
                    this.Remove.Focus();
                }
                else
                {
                    message = "该" + sn + "在数据库中无装配记录，请重新扫描正确的KCC！";
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
                    this.KCCSN_Text.Text = "";
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + message + "');</script>");
                this.KCCSN_Text.Text = "";
            }

       
        
    }
}